#pragma once
#include <iostream>
#include <string>
#include <ctime>
#include <functional>
#include <unordered_map>

void PrintLog()
{
    std::cout << "task for 打印日志" << std::endl;
}

void DownLoad()
{
    std::cout << "task for 下载" << std::endl;
}

void UPLoad()
{
    std::cout << "tas for 上传" << std::endl;
}

class TaskManager
{
public:
    TaskManager() 
    {
        srand(time(nullptr));
    }
    ~TaskManager() {}

    void Register(int code, std::function<void()> task)
    {
        _taskCatalog[code] = task;
    }

    int taskcode()
    {
        int r = rand();
        return r % _taskCatalog.size();
    }

    void Exectue(int taskcode)
    {
        _taskCatalog[taskcode]();
    }

private:
    std::unordered_map<int, std::function<void()>> _taskCatalog;
};